﻿
function loginSubmit() {
	var username = $.trim($("#userName").val());
	var password = $("#password").val();
	var code = $("#loginCode").val();
	if (username.length <= 0) {
		$("#errorInfo").attr("style", "block").text("请输入您的邮箱或昵称");
		$("#userName").focus();
	} else {
		if (password.length <= 0) {
			$("#errorInfo").attr("style", "block").text("请输入您的密码");
			$("#password").focus();
		} else {
			if (code.length <= 0) {
				$("#errorInfo").attr("style", "block").text("请输入验证码");
				$("#loginCode").focus();
			} else {
				//alert("click ok to submit form");
				document.getElementById("loginForm").submit(); // submit form
			}
		}
	}

}

/*
 * function loginSubmit() { var t = document.getElementById("userName"); var p =
 * document.getElementById("password"); var e =
 * document.getElementById("errorInfo"); var s = p.value; var u = t.value; var
 * checkCode = ""; if (document.getElementById("loginCode") != null) { checkCode =
 * document.getElementById("loginCode").value; checkCode.replace(" ", ""); }
 * u.replace(" ", ""); s.replace(" ", ""); if (u.length > 0) { if (s.length > 0) {
 * if (checkCode.length > 3 || document.getElementById("loginCode") == null) {
 * document.getElementById("loginForm").submit(); } else { e.style.display =
 * "block"; e.innerHTML = "请输入验证码";
 * document.getElementById("loginCode").focus(); } } else { e.style.display =
 * "block"; e.innerHTML = "请输入您的密码";
 * document.getElementById("password").focus(); } } else { e.style.display =
 * "block"; e.innerHTML = "请输入您的邮箱或昵称"; t.focus(); } }
 */

function EnterSubmit(e) {
	var c = 0;
	if (navigator.appName == "Microsoft Internet Explorer")
		c = event.keyCode;
	else
		c = e.keyCode;
	if (c == 13) {
		var d = e.srcElement || e.currentTarget;
		if (d == document.getElementById("userName")
				&& document.getElementById("password").value.length <= 0)
			return false;
		loginSubmit();
	}
}